
var removeElement = function (nums, val) {
  let left = 0
  let n = nums.length
  // 将不等于val的数放在nums的左边，最后0，left就是我们要的数组
  for (var right = 0; right < n; right++) {
    if (nums[right] != val) {
      nums[left] = nums[right]
      left++
    }
  }
  return left
};
let nums = [2]
console.log(removeElement(nums, 3));
console.log(nums);